<?php
    /**
    * FILE NAME: show_profile.php
    *
    * FUNCTION:  allows user to edit HBC consumer data  
    *            
    * NOTE:  edited to run on LOCALHOST using XAMPP
    *        
    */
    
    //get your hbc database connection
    include "db_connect.php";
        

    /*********************************************************************************************/

     $cid                     = $_REQUEST['consumer_id'];                 
     $fullname                = $_REQUEST['consumer_fullname'];          

   /*********************************************************************************************/

     $date                    = $_REQUEST['consumer_date'];
     $nursingfacility         = $_REQUEST['consumer_nursing_facility'];
     $nursingfacilityaddress  = $_REQUEST['consumer_nursing_facility_address'];
     $coordinator             = $_REQUEST['consumer_coordinator'];
     $casenote                = $_REQUEST['consumer_case_note'];
     $isn                     = $_REQUEST['consumer_isn'];
     $status                  = $_REQUEST['consumer_status'];



     $pageaction              = $_REQUEST['pageaction'];
     $change                  = $_REQUEST['change'];   

   /***********************************************************************************************/


    //handles all EDIT->UPDATE FUNCTIONS 

    if($pageaction=="update"){
      
      //if this prints you are in conditional section
      
      // print_r ($pageaction);  FOR DEBUGGING PURPOSES


      //UPDATE CONSUMER FULLNAME
      if($fullname!=""){
           
	     //echo('you are in fullname option'); FOR DEBUGGING

         $file_update = "UPDATE `hbc_consumers` 
                         SET `hbc_consumers`.`consumer_fullname`='$fullname' 
                         WHERE `hbc_consumers`.`consumer_id`='$cid'";
             
         $result_of_updated_file = mysql_query($file_update) 
                                   or die(mysql_error());
              
      }
      
      //UPDATE CONSUMER DATE
      if($date!=""){
           
	     //echo('you are in fullname option'); FOR DEBUGGING

         $file_update = "UPDATE `hbc_consumers` 
                         SET `hbc_consumers`.`consumer_date`='$date' 
                         WHERE `hbc_consumers`.`consumer_id`='$cid'";
             
         $result_of_updated_file = mysql_query($file_update) 
                                   or die(mysql_error());
              
      }
      
      //UPDATE CONSUMER STATUS
      elseif($status!=""){

         $file_update = "UPDATE `hbc_consumers` 
                         SET `hbc_consumers`.`consumer_status`='$status' 
                         WHERE `hbc_consumers`.`consumer_id`='$cid'";
             
         $result_of_updated_file = mysql_query($file_update) 
                                   or die(mysql_error());

      }
      
      //UPDATE HBC SPECIALIST ASSIGNED
      elseif($coordinator!=""){

         $file_update = "UPDATE `hbc_consumers` 
                         SET `hbc_consumers`.`consumer_coordinator`='$coordinator' 
                         WHERE `hbc_consumers`.`consumer_id`='$cid'";
             
         $result_of_updated_file = mysql_query($file_update) 
                                   or die(mysql_error());

      }
      
      //UPDATE CONSUMER ISN
      elseif($isn!=""){

         $file_update = "UPDATE `hbc_consumers` 
                         SET `hbc_consumers`.`consumer_isn`='$isn' 
                         WHERE `hbc_consumers`.`consumer_id`='$cid'";
             
         $result_of_updated_file = mysql_query($file_update) 
                                   or die(mysql_error());

      }
      
      //UPDATE NURSING FACILITY INFO
      elseif($nursingfacility!=""){

         $file_update = "UPDATE `hbc_consumers` 
                         SET `hbc_consumers`.`consumer_nursing_facility`='$nursingfacility' 
                         WHERE `hbc_consumers`.`consumer_id`='$cid'";
             
         $result_of_updated_file = mysql_query($file_update) 
                                   or die(mysql_error());

      }
      
      //UPDATE NURSING FACILITY ADDRESS
      elseif($nursingfacilityaddress!=""){

         $file_update = "UPDATE `hbc_consumers` 
                         SET `hbc_consumers`.`consumer_nursing_facility_address`='$nursingfacilityaddress' 
                         WHERE `hbc_consumers`.`consumer_id`='$cid'";
             
         $result_of_updated_file = mysql_query($file_update) 
                                   or die(mysql_error());

      }
      
      //UPDATE CONSUMER CASENOTE
      elseif($casenote!=""){

         $file_update = "UPDATE `hbc_consumers` 
                         SET `hbc_consumers`.`consumer_case_note`='$casenote' 
                         WHERE `hbc_consumers`.`consumer_id`='$cid'";
             
         $result_of_updated_file = mysql_query($file_update) 
                                   or die(mysql_error());

      }
      
      

   }//end UPDATE FUNCTIONS
    

   /*---------------------------------------------
      GET ALL YOUR DATA TO POPULATE THIS FORM
   ----------------------------------------------*/   
   
   /* GETS the CONSUMER RECORD */
       $Select_consumer= "SELECT * 
                          FROM `hbc_consumers`  
                          WHERE `consumer_id`='$cid'";

                          
   /* HOLDS CONSUMER RECORD data */                 
       $Query_consumer = mysql_query($Select_consumer) or die(mysql_error());
        
       $fetch_consumer_info = mysql_fetch_array($Query_consumer);
        
       $cid                     = $fetch_consumer_info['consumer_id'];                 
       $fullname                = $fetch_consumer_info['consumer_fullname'];          
       $date                    = $fetch_consumer_info['consumer_date'];
       $nursingfacility         = $fetch_consumer_info['consumer_nursing_facility'];
       $nursingfacilityaddress  = $fetch_consumer_info['consumer_nursing_facility_address'];
       $coordinator             = $fetch_consumer_info['consumer_coordinator'];
       $casenote                = $fetch_consumer_info['consumer_case_note'];
       $isn                     = $fetch_consumer_info['consumer_isn'];
       $status                  = $fetch_consumer_info['consumer_status'];


?>



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                      "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Home By Choice Consumer Management - Edit Consumer File Page</title>
    <style type="text/css">
        .style11 {color: #FF0000}

        a:hover {
            font-weight: bold;
            background-color: #FFFFA4;
        }

        #control_panel_banner{
           font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 28px;
           font-weight: bold;
           color: #7B67AA; 
           text-align: center;
           border-top: 1px dashed #674495;
           border-bottom: 1px dashed #674495;
           background-color: #FFBB62; 
        }

	   h2{
           font-family: Verdana, Helvetica, Arial, sans-serif;
           color: #7B67AA; 
           border-top: 1px dashed #674495;
           border-bottom: 1px dashed #674495;
           border-left: 15px solid #EAD170;
           border-right: 15px solid #EAD170;
           background-color: #FFFF9D;
        }
    </style>
    <link href="images/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<table align="center" border="0px" cellpadding="0px" cellspacing="0px" width="780px">
   <tbody>
      <tr>
         <td>
            <table border="0px" cellpadding="0px" cellspacing="0px" width="10px">
               <tbody>
	          <tr>
                    <td>
		       <table border="0px" bordercolor="#ffffff" cellpadding="0" cellspacing="0" width="780">
		          <form name="editcolor" method="get" action="" >
		             <tbody>
			        <tr>
				   		<td class="style" colspan="4" style="padding-top:10px;">
                        	<div id="control_panel_banner" >
                            	<H4>HBC Consumer Profile</H4>
                            </div>
                        </td>
					</tr>
		            <tr>
                        <td bgcolor="#FFFFFF">&nbsp;</td>
                    </tr>
			        <tr>
                        <td colspan="4">
                        
                        
                        

                   	     <!-- CONSUMER PROFILE TABLE -->
                         <table width="100%" border="1" cellpadding="10" cellspacing="0" >

                    		<form name="editinfo" action="show_profile.php" method="post"> 
                                <input type="hidden" name="pageaction" value="update">
                                <input type="hidden" name="consumer_id" value="<?=$cid?>">

					   
                             <!--  BEGIN 1st ROW -->
                             <tr>

                            	  <!-- FULLNAME -->
                                <td colspan="2" bgcolor="#FFFF9D">
						     		        <b>Name:&nbsp;</b>
                                    
						     		        <?php 
                                     
						     		          //EDIT CONSUMER FULLNAME                  
                                     if($change == "fullname"){

                                       echo "<input type=\"text\" 
                                                    name=\"consumer_fullname\" 
                                                    value=\"".$fullname."\" 
                                                    maxlength=\"45\" 
                                                    size=\"15\">
                                                             
                                            <input style=\"font-size:13px; color:black;\" 
                                                   type=\"submit\" 
                                                   name=\"submit\" 
                                                   value=\"Update\">";
                                                        
                                    }else{

	                                   //JUST SHOW FULLNAME
                                       echo "
                                            ".$fullname."
                                            <a href=\"show_profile.php?consumer_id=$cid&change=fullname\">
                                               <img src=\"./ico_edit.gif\" border=0>
                                            </a>
                                            "; 
                                     }

                                    ?>
                               </td>
                               <!-- END FULLNAME-->

                               
                               <!-- CONSUMER DATE -->
                               <td colspan="1" bgcolor="#FFFF9D">
                                  <b>Date of Current Status:</b>
   
						     		        <?php 
                                     
						     		          //EDIT CONSUMER DATE                  
                                     if($change == "date"){

                                       echo "<input type=\"text\" 
                                                    name=\"consumer_date\" 
                                                    value=\"".$date."\" 
                                                    maxlength=\"10\" 
                                                    size=\"10\">
                                                             
                                            <input style=\"font-size:13px; color:black;\" 
                                                   type=\"submit\" 
                                                   name=\"submit\" 
                                                   value=\"Update\">";
                                                        
                                    }else{

	                                   //JUST SHOW FULLNAME
                                       echo "
                                            ".$date."
                                            <a href=\"show_profile.php?consumer_id=$cid&change=date\">
                                               <img src=\"./ico_edit.gif\" border=0>
                                            </a>
                                            "; 
                                     }

                                    ?>

                               </td>
                               
                              <!-- CONSUMER ID -->
                               <td colspan="1" bgcolor="#FFFF9D">
                                  <b>Consumer ID:&nbsp;&nbsp;&nbsp;# &nbsp;</b>
   
                                  <?php
                                  
                                  //JUST ECHO - CAN NOT BE EDITED 
                                  echo"".$cid."&nbsp;";
                                  
                                  ?>

                               </td>
                            </tr>
                            <!-- END 1st ROW -->
			                         
                            
                            
                            
                            <!-- BEGIN 2nd ROW -->
                            <tr>
                                                   
                            	<!-- CONSUMER STATUS -->
                                <td colspan="2" bgcolor="#FFFF9D">
                                                       
                                	<b>Status:</b>&nbsp;
                                    
                                	<?php 

                                	//EDIT CONSUMER STATUS
                                    if($change=="status"){
                                                      
                                       echo"
                                            <select name=\"consumer_status\" value=\"".$status."\">
                                            	<option value=\"invalid \">--- Select Consumer Status ---</option>
                                            	<option value=\"service requested \">Requested HBC Services</option>
                                                <option value=\"assessed \">Assessed</option>
                                                <option value=\"reassessed \">Re-assessed</option>
                                                <option value=\"relocation planned \">Relocation Planned</option>
                                                <option value=\"relocation completed \">Relocation Completed</option>
                                                <option value=\"follow up \">Follow-Up</option>
                                                <option value=\"no longer in HBC \">No longer in HBC</option>
                                            </select>
                                            
                                            <input style=\"font-size:13px; color:black\" 
                                            	type=\"submit\" 
                                                name=\"submit\" 
                                                value=\"Update\">
                                          ";

                                    }else{
 
	                                    //JUST SHOW CONSUMER STATUS
                                        echo"
                                            ".$status."&nbsp;
                                              <a href=show_profile.php?consumer_id=$cid&change=status>
                                                 <img src=\"ico_edit.gif\" border=0>
                                              </a>
                                            ";
                                    }
                                    
                                    ?>
                                </td>
                                <!-- END CONSUMER STATUS-->
                                                    

                                <!-- BEGIN HBC SPECIALIST ASSIGNED -->
                                <td colspan="2" bgcolor="#FFFF9D">
                                                    
                                   <b>HBC Specialist Assigned:&nbsp;</b>
                                                         
                                   <?php 
                                   
                                   //EDIT HBC SPECIALIST 
                                   if($change=="coordinator"){
                                   
	                                   echo"	                                        
	                                        <input type=\"text\" 
                                                   name=\"consumer_coordinator\" 
                                                    value=\"".$coordinator."\" 
                                                    maxlength=\"45\" 
                                                    size=\"15\">
	                                        
                                            <input style=\"font-size:13px; color:black\" 
                                                   type=\"submit\" 
                                                   name=\"submit\" 
                                                   value=\"Update\">
                                            ";
                                                             
                                    }else{
                                    
	                                    //JUST ECHO COORDINATOR NAME
	                                    echo"
	                                        ".$coordinator."&nbsp;
                                              <a href=show_profile.php?consumer_id=$cid&change=coordinator>
                                                 <img src=\"ico_edit.gif\" border=0>
                                              </a>"; 
                                    }
                                    
                                    ?>
                                </td>
                                <!-- END HBC SPECIALIST ASSIGNED -->
                             
                           </tr>
                           <!-- END 2nd ROW -->
                                                      
                                                      
                                                      
                                                      
                           <!-- BEGIN 3rd ROW -->                           
                           <tr>
                           
                                <!-- BEGIN INTENSE SERVICE NEED -->
                           		<td colspan="2" bgcolor="#FFFF9D">
                                	<b>Intense Service Needs?&nbsp;</b> 
                                    
                                	<?php 
                                	
                                	//EDIT INTENSE SERVICE NEED
                                	if($change=="isn"){
                                    	                                                    
                                        echo"
                                            <select name=\"consumer_isn\" value=\"".$isn."\">
                                            	<option value=\"invalid \">--- ---</option>
                                                <option value=\"no \">No</option>
                                                <option value=\"yes \">Yes</option>
                                            </select>
                                            
                                            <input style=\"font-size:13px; color:black\" 
                                            	type=\"submit\" 
                                                name=\"submit\" 
                                                value=\"Update\">
                                          ";
                                    }else{
                                    
	                                    //JUST SHOW ISN
	                                    echo"
	                                    	".$isn."&nbsp;
                                        	<a href=show_profile.php?consumer_id=$cid&change=isn>
                                            	<img src=\"ico_edit.gif\" border=0>
                                            </a>"; 
                                                             
                                    }
                                    
                                    ?>
                               </td>
                               <!-- END INTENSE SERVICE NEED -->                          
                               
                               
                               <!-- BEGIN NURSING FACILITY RESIDENCE  -->
                               <td colspan="2" bgcolor="#FFFF9D">
                               		<b>Nursing Facility Residence:&nbsp;</b> 
                                                             
                               		<?php 
                               		
                               		//EDIT NURSING FACILITY INFO
                               		if($change=="nursingfacility"){
                                       echo"
	                                        <input type=\"text\" 
                                                   name=\"consumer_nursing_facility\" 
                                                    value=\"".$nursingfacility."\" 
                                                    maxlength=\"65\" 
                                                    size=\"35\">
                                            
                                            <input style=\"font-size:13px; color:black\" 
                                                   type=\"submit\" name=\"submit\" 
                                                   value=\"Update\">";
                                                             
                                                   
                                    }else{
                                                                
	                                   //JUST SHOW NURSING FACILITY 
	                                   echo"
	                                       ".$nursingfacility."&nbsp;
                                            <a href=show_profile.php?consumer_id=$cid&change=nursingfacility>
                                               <img src=\"ico_edit.gif\" border=0>
                                            </a>"; 
                                    }
                                    
                                    ?>
                                </td>
                                <!-- END NURSING FACILITY RESIDENCE -->
                                                      
                            </tr>
                            <!-- END 3rd ROW -->
                            
                            
                            <!-- BEGIN 4th ROW -->
				            <tr>
				            
				                <!-- BEGIN NF ADDRESS INFO -->
                            	<td colspan="4" bgcolor="#FFFF9D">
                                	<b>Nursing Facility Address:&nbsp;</b><br />
                                    
                                	<?php 
                                	
                                	//EDIT NF ADDRESS INFORMATION
                                	if($change == "nursingfacilityaddress"){
                                    	echo"<input type=\"text\" 
                                    	            name=\"consumer_nursing_facility_address\" 
                                    	            value=\"".$nursingfacilityaddress."\" 
                                                    maxlength=\"65\" 
                                                    size=\"65\">
                                                                 
                                              <input style=\"font-size:13px; color:black\" 
                                                     type=\"submit\" name=\"submit\" 
                                                     value=\"Update\">";
                                               
                                    }else{
	                                         
                                         //JUST SHOW NF ADDRESS
	                                     echo"
	                                         ".$nursingfacilityaddress."&nbsp;&nbsp;
                                               <a href=show_profile.php?consumer_id=$cid&change=nursingfacilityaddress>
                                                 <img src=\"ico_edit.gif\" border=0>
                                               </a>"; 
                                   }
                                         
                                   ?>
                                 </td>
                                 <!-- END NF ADDRESS INFO -->
                                 
                          </tr>
                          <!-- END 4th ROW  -->
				                                          
                          <!-- BEGIN 5th ROW  -->
                          <tr>
                          
                                <!-- CASE NOTES -->
                          		<td colspan="4" bgcolor="#FFFF9D">
                                	<b>Latest Case Note:&nbsp;</b>
                                	<br />
                                    
                                	<?php 
                                	
                                	if($change=="casenote"){
                           	
	                                	echo"<input type=\"text\" 
	                                	            name=\"consumer_case_note\" 
	                                	            value=\"".$casenote."\" 
                                                    maxlength=\"255\" 
                                                    size=\"85\">
                                        
                                             <input style=\"font-size:13px; color:black\" 
                                                    type=\"submit\" 
                                                    name=\"submit\" 
                                                    value=\"Update\">";
                                                               
                                    }else{
                                      
	                                    echo"
	                                        ".$casenote."&nbsp;&nbsp;
                                            <a href=show_profile.php?consumer_id=$cid&change=casenote>
                                               <img src=\"ico_edit.gif\" border=0>
                                            </a>"; 
                                                               
                                    }
                                    
                                    ?>
                                </td>
                            </tr>
                            
                            
                            
                            
                            
						                                   </form>
                                                 </table>
                                              </td>
                                           </tr>
                                           <tr bgcolor="#ffffff">
                                               <TD bgColor=#ffffff>&nbsp;</TD>
                                           </tr>
							                      <tr bgcolor="#ffffff">
			                                  <tr>
							                         <td colspan="6" align="center" style="padding-top:10px;padding-bottom:10px;">
							                           <b>
                                                   <a href=./index.php>
                                                      Return to HBC Consumer Management Page
                                                   </a>
                                                 </b>
                                              </td>
								                  </tr>
							                    </table>
							                </td>
							            </tr>
							            <tr bgcolor="#ffffff">
							            <tr bgcolor="#ffffff">
							               <td align="center">&nbsp;</td>
							            </tr>
            							<TR bgColor=#FFBB62>
                                  <TD bgColor=#FFBB62>&nbsp;</TD>
                                </TR>
					          </tbody>
				              </form>
			                 </table>
		                   </td>
	                    </tr>
                     </tbody>
                  </table>
               </td>
            </tr>
         </tbody>
      </table>
   </body>
</html>